<?php
namespace app\content\controller;
use think\admin\Controller;
use app\index\model\Banner as BannerModel;
use app\index\model\DataUser;
use app\model\Apply;
use app\model\Cassette as ModelCassette;
use app\model\Merchant;;
use app\model\MerchantCate;
use think\admin\helper\QueryHelper;

class MerchantApply  extends Controller{

     /**
     * @auth true
     * @menu true
     */
    public function index(){
        $search = input('get.');
        Apply::mQuery()->layTable(function () {
            $this->title = '申请列表';
            $this->cate_list = MerchantCate::select();
        }, function (QueryHelper $query) use ($search) {
            // 数据列表搜索过滤
            $query->with('cate')->like('name');
        });
    }



     /**
     * @auth true
     * @menu true
     */
    public function remove()
    {
        $this->_delete('merchant_apply');
    }

     /**
     * @auth true
     * @menu true
     */
    public function pass()
    {
     
        ModelCassette::mSave($this->_vali([
            'status.in:0,1'  => '状态值范围异常！',
            'status.require' => '状态值不能为空！',
        ]));
    }

     /**
     * @auth true
     * @menu true
     */
    public function reject(){
        if(request()->isPost()){
            $data = input('post.');
            $res = Apply::where('id',$data['id'])->update(['status'=>2,'reject_reason'=>$data['reject_reason']]);
            if($res){
                return $this->success('操作成功');
            }else{
                return $this->error('操作失败');
            }
        }
        $this->_form('merchant_apply','reject');
    }
}